package Test;

import java.awt.*;

public class 相交链表 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode a,b;
        a=headA;
        b=headB;
        while (a!=b){
            if(a==null) a=headB;
            else {
                a=a.next;
            }
            if(b==null) b=headA;
            else {
                b=b.next;
            }

        }
        return a;
    }
}
